home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / ex8-12.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  1KB  |  38 lines

  1. // ex8-12.c -- Binary Set operators
  2.  
  3. // $Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/ex8-12.c,v 3.0 90/05/15 22:46:03 kgorlen Rel $
  4.  
  5. #include "Patient.h"
  6. #include "Set.h"
  7. #include "SortedCltn.h"
  8.  
  9. main()
  10. {
  11.     Patient p1("Smith John A.","111-22-3333",22222);
  12.     Patient p2("Fried Harry I.","123-45-6789",20892);
  13.     Patient p3("Chavez Maria G.","444-555-6666",22223);
  14.     Patient p4("Doe, Jane B.","123-98-7654",20892);
  15.  
  16.     Set males;                  // set of all male Patients
  17.     males.add(p1); males.add(p2);
  18.     Set females;                // set of all female Patients
  19.     females.add(p3); females.add(p4);
  20.     Set washingtonResidents;    // set of all Patients living
  21.                                 // in Washington
  22.     washingtonResidents.add(p2); washingtonResidents.add(p4);
  23.  
  24.     cout << "All patients:\n";
  25.     cout << (males | females).asSortedCltn() << endl;
  26.  
  27.     cout << "\nAll female patients living in Washington:\n";
  28.     cout << (females & washingtonResidents).asSortedCltn() << endl;
  29.  
  30.     cout <<
  31.       "\nAll female patients living outside of Washington:\n";
  32.     cout << (females - washingtonResidents).asSortedCltn() << endl;
  33.  
  34.     cout << "\nDo all male patients live in Washington? "; 
  35.     cout << (males == (males & washingtonResidents) ? "Yes" : "No")
  36.         << endl;
  37. }
  38.